<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}SteHub - 学生交流平台{% endblock %}</title>
    
    <!-- Bootstrap 5 CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <!-- 自定义CSS -->
    <link href="{{ url_for('static', filename='css/main.css') }}" rel="stylesheet">
    
    {% block extra_css %}{% endblock %}
</head>
<body>
    <!-- 导航栏 -->
    <nav class="navbar navbar-expand-lg navbar-dark bg-primary">
        <div class="container">
            <a class="navbar-brand" href="{{ url_for('main.index') }}">
                <i class="fas fa-graduation-cap me-2"></i>
                SteHub
            </a>
            
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav me-auto">
                    <li class="nav-item">
                        <a class="nav-link" href="{{ url_for('main.index') }}">
                            <i class="fas fa-home me-1"></i>首页
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="{{ url_for('forum.posts') }}">
                            <i class="fas fa-comments me-1"></i>论坛
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="{{ url_for('chat.index') }}">
                            <i class="fas fa-comment-dots me-1"></i>聊天
                        </a>
                    </li>
                </ul>
                
                <ul class="navbar-nav">
                    {% if current_user.is_authenticated %}
                        <li class="nav-item dropdown">
                            <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown">
                                <i class="fas fa-user me-1"></i>{{ current_user.username }}
                            </a>
                            <ul class="dropdown-menu">
                                <li>
                                    <a class="dropdown-item" href="{{ url_for('auth.profile') }}">
                                        <i class="fas fa-id-card me-2"></i>个人资料
                                    </a>
                                </li>
                                <li>
                                    <a class="dropdown-item" href="{{ url_for('main.dashboard') }}">
                                        <i class="fas fa-tachometer-alt me-2"></i>仪表板
                                    </a>
                                </li>
                                {% if current_user.is_admin %}
                                <li>
                                    <a class="dropdown-item" href="{{ url_for('admin.dashboard') }}">
                                        <i class="fas fa-cog me-2"></i>管理面板
                                    </a>
                                </li>
                                {% endif %}
                                <li><hr class="dropdown-divider"></li>
                                <li>
                                    <a class="dropdown-item" href="{{ url_for('auth.logout') }}">
                                        <i class="fas fa-sign-out-alt me-2"></i>退出登录
                                    </a>
                                </li>
                            </ul>
                        </li>
                    {% else %}
                        <li class="nav-item">
                            <a class="nav-link" href="{{ url_for('auth.login') }}">
                                <i class="fas fa-sign-in-alt me-1"></i>登录
                            </a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link" href="{{ url_for('auth.register') }}">
                                <i class="fas fa-user-plus me-1"></i>注册
                            </a>
                        </li>
                    {% endif %}
                </ul>
            </div>
        </div>
    </nav>

    <!-- 主要内容 -->
    <main class="container mt-4">
        <!-- 闪存消息 -->
        {% with messages = get_flashed_messages(with_categories=true) %}
            {% if messages %}
                {% for category, message in messages %}
                    <div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
                        {{ message }}
                        <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
                    </div>
                {% endfor %}
            {% endif %}
        {% endwith %}
        
        {% block content %}{% endblock %}
    </main>

    <!-- 页脚 -->
    <footer class="bg-dark text-light mt-5 py-4">
        <div class="container">
            <div class="row">
                <div class="col-md-6">
                    <h5><i class="fas fa-graduation-cap me-2"></i>SteHub</h5>
                    <p class="mb-0">连接每一个热爱学习的学生，让交流更简单，让成长更精彩！</p>
                </div>
                <div class="col-md-3">
                    <h6>快速链接</h6>
                    <ul class="list-unstyled">
                        <li><a href="{{ url_for('main.about') }}" class="text-light">关于我们</a></li>
                        <li><a href="{{ url_for('main.help') }}" class="text-light">使用帮助</a></li>
                        <li><a href="{{ url_for('main.contact') }}" class="text-light">联系我们</a></li>
                    </ul>
                </div>
                <div class="col-md-3">
                    <h6>技术支持</h6>
                    <ul class="list-unstyled">
                        <li><a href="#" class="text-light">API文档</a></li>
                        <li><a href="#" class="text-light">问题反馈</a></li>
                        <li><a href="#" class="text-light">更新日志</a></li>
                    </ul>
                </div>
            </div>
            <hr class="bg-light">
            <div class="row">
                <div class="col-md-6">
                    <small>&copy; {{ current_year }} SteHub. 保留所有权利。</small>
                </div>
                <div class="col-md-6 text-md-end">
                    <small>版本 {{ app_version }} | {{ '本地模式' if config.RUN_MODE == 'local' else '云端模式' }}</small>
                </div>
            </div>
        </div>
    </footer>

    <!-- Bootstrap 5 JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <!-- Socket.IO -->
    <script src="https://cdn.socket.io/4.7.2/socket.io.min.js"></script>
    <!-- 自定义JS -->
    <script src="{{ url_for('static', filename='js/main.js') }}"></script>
    
    {% block extra_js %}{% endblock %}
</body>
</html>